/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.ball.views.obstacles
{
	import com.puny.mvc.helpers.FrameHelper;
	import com.puny.mvc.helpers.IHelper;
	
	import flash.events.Event;
	
	public class RotatingCircleObstacle extends CirculerShapeObstacle
	{
		private static var _sign:Number = 1;
		private var _w:Number = 5;
		private var _helper:IHelper;
		public function RotatingCircleObstacle()
		{
			_w = _sign * _w;
			_sign = -1 * _sign;
			super(_w);
		}
		
		override protected function addedStageHandler(event:Event):void {
			super.addedStageHandler(event);
			_helper = FrameHelper.setup(this, null, loop, null);
		}

		private function loop():Boolean {
			rotation += _w;
//			_cpa.rotation = rotation;
//			_r1.rotation += _w;
//			_r2.rotation += _w;
			return true;
		}

		override protected function removedStageHandler(event:Event):void {
			_helper.cancel();
			super.removedStageHandler(event);
		}
	}
}